package jdbcTemplate.service;

import jdbcTemplate.dao.BookDao;
import jdbcTemplate.model.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wang fei
 * @date 2020-10-11 17:10
 */
@Service
public class BookService {

    //注入BookDao
    @Autowired
    private BookDao bookDao;

    //添加
    public void update(Book book){
        bookDao.add(book);
    }

    // 更改
    public void updateBook(Book book){
        bookDao.updateBook(book);
    }
    // 删除
    public void delBook(Book book){
        bookDao.delBook(book);
    }

    //数量
    public int foundSize(){
        return bookDao.foundSize();
    }

    //单个对象
    public Book findOne(int userId){
        return bookDao.findOne(userId);
    }

    //多个对象，集合
    public List<Book> listBook(){
        return bookDao.listBook();
    }

}
